﻿// ==UserScript==
// @name       google-tasks-backup
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description  enter something useful
// @match      https://mail.google.com/tasks/canvas?pli=1
// @copyright  2012+, You
// ==/UserScript==

console.log("google-tasks-backup started");

var w = window.open("", "");
var lists = [];

window.setInterval(function () {

    console.log("google-tasks-backup interval");

    var listName = document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementById(":1.lt").innerText;

    if (lists[listName] == null) {
        //debugger;
        lists[listName] = true;
        w.document.write("<p>" + listName + "</p><ul>");
        var tasks = document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementsByClassName("d");

        for (var i = 0; i < tasks.length; i++) {
            console.log(tasks[i].innerText);
            w.document.write("<li>" + tasks[i].innerText + "</li>");
        }
        w.document.write("</ul>");
    }
    console.log("google-tasks-backup interval over");
}, 1000);


// var tasks = document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementsByClassName("d")
// for (var i in tasks) { console.log(tasks[i].innerText); }